<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <!--    <script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.2"></script>-->
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
</head>
<body>
<div id="app_vr">
    推荐使用axios
    vue-resource源码地址 : https://github.com/pagekit/vue-resource<br/>
    <input type="button" value="v-resource Get请求" v-on:click="getInfoGet"/><br/>
    <input type="button" value="v-resource Post请求" v-on:click="getInfoPost"/><br/>
    <input type="button" value="v-resource JSONP请求" @click="getInfoJsonP">

</div>

<script>
    new Vue({
        el: '#app_vr',
        data: {},
        methods: {
            getInfoGet() {
                this.$http.get('http://localhost:8080/find/get', {params: {id: 2}}).then(response => {
                    console.log(response);
                }, response => {
                    console.log(response);
                })
            },
            getInfoPost() {
                // header('Access-Control-Allow-Origin: *');
                // header('Access-Control-Allow-Methods: POST');
                // header('Access-Control-Max-Age: 1000');
                // 'Access-Control-Allow-Origin':'*','Access-Control-Allow-Methods':'POST','Access-Control-Max-Age':1000
                this.$http.post('http://localhost:8080/find/post', {'id': 1}, {emulateJSON:true}).then(response => {
                    console.log(response);
                }, response => {
                    console.log(response)
                })
            },
            getInfoJsonP() {
                this.$http.jsonp('http://localhost:8080/find/jsonp', {params: {id: 1}}).then(response => {
                    console.log(response);
                }, response => {
                    console.log(response);
                })
            }
        }
    })
</script>
</body>
</html>